package com.sj.uabrowser.mvp.settings.view.act;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.Switch;
import android.widget.TextView;

import com.sj.uabrowser.R;
import com.sj.uabrowser.app.Constant;
import com.sj.uabrowser.app.SPUtil;
import com.sj.uabrowser.app.StatusBarUtil;
import com.sj.uabrowser.app.Util;
import com.sj.uabrowser.framework.BaseActivity;
import com.sj.uabrowser.framework.BasePresenter;
import com.sj.uabrowser.net.bean.AboutMe;

import butterknife.BindView;
import butterknife.OnClick;

public class SettingsAct extends BaseActivity {

    @BindView(R.id.tv_font)
    TextView tvFont;
    @BindView(R.id.rl_font)
    RelativeLayout rlFont;
    @BindView(R.id.switch_recovery)
    Switch switchRecovery;
    @BindView(R.id.rl_recovery)
    RelativeLayout rlRecovery;
    @BindView(R.id.switch_default_browser)
    Switch switchDefaultBrowser;
    @BindView(R.id.rl_default_browser)
    RelativeLayout rlDefaultBrowser;
    @BindView(R.id.rl_feedback)
    RelativeLayout rlFeedback;
    @BindView(R.id.tv_version)
    TextView tvVersion;

    @Override
    public BasePresenter createPresenter() {
        return null;
    }

    @Override
    public int getLayoutID() {
        return R.layout.activity_settings;
    }

    @Override
    public void setView() {
        StatusBarUtil.setTranslucentForImageViewInFragment(this,0,null);
        StatusBarUtil.setLightMode(this);
        setTopTitle("设置");
        setFontSize();
//        tvVersion.setText(Util.getVersionName());
    }

    private void setFontSize() {
        int fontSize = SPUtil.get(this,SPUtil.KEY_FONTSIZE, Constant.FONTSIZE_NORMAL);
        if(fontSize==Constant.FONTSIZE_NORMAL){
            tvFont.setText("默认");
        }else if(fontSize==Constant.FONTSIZE_SMALL){
            tvFont.setText("小字体");
        }else if(fontSize==Constant.FONTSIZE_LARGE){
            tvFont.setText("大字体");
        }
    }

    @Override
    public void setData() {

    }



    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==0){
            setFontSize();
        }
    }

    @OnClick({R.id.rl_font, R.id.rl_feedback,R.id.yinsizhengce,R.id.rl_version})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.rl_font:
                Intent intent = new Intent(this,SettingFontAct.class);
                startActivityForResult(intent,0);
                break;
            case R.id.rl_feedback:
                startActivity(new Intent(this,FeedBackAct.class));
                break;
            case R.id.yinsizhengce:
                startActivity(new Intent(this, PrivacyAct.class));
                break;
            case R.id.rl_version:
                startActivity(new Intent(this, AboutUsAct.class));
                break;
        }
    }
}
